"""
客户页面
"""
from selenium.webdriver.common.by import By
from page.base_page import BasePage
from selenium.webdriver.support.select import Select
from time import sleep



class ClientPage(BasePage):
    url="/crm/index.php?m=customer"
    #定位器
    add_client_locator = (By.LINK_TEXT, "新建客户")
    check_all_client_locator=(By.XPATH,'//*[@id="form1"]/table/tbody/tr[1]/td[1]/input')
    piliang_caozuo_locator = (By.LINK_TEXT, '批量操作')
    detele_locator=(By.ID,"delete")

    #操作
    #点击新建客户
    def click_add_client(self):
        self.driver.find_element(*self.add_client_locator).click()

    #删除所选用户
    def delete_add_client(self):
        self.driver.find_element(*self.check_all_client_locator).click()
        self.driver.find_element(*self.piliang_caozuo_locator).click()
        sleep(1)
        self.driver.find_element(*self.detele_locator).click()
        self.driver.switch_to.alert.accept()


    # 返回表格对象
    def get_table_element(self, table_loc, row, cell):
        row = str(row)
        cell = str(cell)
        locator = table_loc[1] + "/tbody/tr[" + row + "]/td[" + cell + "]" + "/a/span"
        text = self.driver.find_element(By.XPATH, locator).text
        return text


